<?php 

class Images_Model_Manager extends Zend_Cache_Backend_File {
	
	private $_path = null;
	
	private $_id = null;
	
	protected $_options = array(
        'cache_dir' => null,
        'file_locking' => true,
        'read_control' => true,
        'read_control_type' => 'adler32',
        'hashed_directory_level' => 2,
        'hashed_directory_umask' => 0777,
        'file_name_prefix' => 'imgsrc',
        'cache_file_umask' => 0777,
        'metadatas_array_max_size' => 100
    );
    
    private $_file_path = null;
    
    public function setFilePath($value) {
    	$this->_file_path = $value;
    	return $this;
    }
    
	public function setId($value) {
    	$this->_id = $value;
    	return $this;
    }
    
    public function getUrl() {
		$file_id = $this->_id;
        $path = $this->_path($file_id);
    	if ($this->_options['hashed_directory_level'] > 0) {
            if (!is_writable($path)) {
                // maybe, we just have to build the directory structure
                $this->_recursiveMkdirAndChmod($file_id);
            }
            if (!is_writable($path)) {
                return false;
            }
        }
        
        $source = $this->_file_path;
        $file_name = basename($this->_file_path);
        $path .= $file_name;
        $this->_path = $path;
        $url = str_replace ( ROOT_PATH, '', $path );
        $url = str_replace ( '\\', '/', $url );
        return $url;
    }
    
	public function getPath() {
    	return $this->_path;
    }
    
    /**
     * 
     * Method copies file to folder structure
     * @param unknown_type $data
     * @param unknown_type $id
     * @param unknown_type $tags
     * @param unknown_type $specificLifetime
     * return file_path
     */
    
	public function copy() {
    	$source = $this->_file_path;
    	$dest = $this->_path;
    	copy($source, $dest);
    	unlink($source);
    	return ;
    }
	
}